package kr.hkit.powerjava.chapter22.work;
/*CH 22 PROGRAMMING */
import java.util.*;

class Lotto{
	Set<Integer> lottoSet = new HashSet<>();
	int lottoNum;
	public void getNum(){
		lottoNum = (int) (Math.random()*45)+1;
		System.out.print(lottoNum +"\t");
	}
	
	public boolean checkNum(){
		return lottoSet.contains(lottoNum);
	}
	
	public void setNum(){
		lottoSet.add(lottoNum);
	}
	
	public void prnNum(){
		System.out.println("추출된 랜덤 로또번호 : " + lottoSet);
	}
	
	public int sizeNum(){
		return lottoSet.size();
	}
}
class SizeException extends Exception{
	public SizeException() {
		super("<중복된 숫자 출현>!! 다시 실행해 주세요!!");
	}
}

public class LottoTest {
	public static void main(String[] args) throws SizeException {
		Lotto t1 = new Lotto();
		int i = 0;
		while(i<6){
		t1.getNum();	
		System.out.print(":["+t1.checkNum()+"]"+"  ");
		t1.setNum();
		i++;
		}
		System.out.println();
		System.out.println("번호의 갯수 : " + t1.sizeNum());
		try{
			if(t1.sizeNum() < 6){
				throw new SizeException();
			}
		}catch(SizeException e){
			System.out.println(e.getMessage());
		}
		t1.	prnNum();
	}
}



